<?php

namespace App\Http\Controllers\Api\V1;

use App\Models\Activity;
use App\Models\Search;
use App\Http\Controllers\Api\V1\Resources\PointsProductResource;
use App\Http\Controllers\Api\V1\Resources\ActivityItemResource;

class ActivitiesController extends Controller
{
    
   

    public function index()
    {
        $keyword = request('keyword');
        ActivityResource::wrap('data');

        $query = Activity::query();

        
        if($keyword){
            $query = $query->where('title', 'like', "%{$keyword}%");
        }

         $activities = $query->orderByDesc('id')->paginate();
        
       
        return ActivityResource::collection($activities);
    }

     public function show($id)
   {

      $activity = Activity::find($id);
      return new  ActivityItemResource($activity);
   }
}
